# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
#   Mayor.create(name: 'Emanuel', city: cities.first)

DatabaseCleaner.clean_with :truncation , :only => ['authors','books']

10.times do |n|
  Author.create do |a|
    a.name = Faker::Name.name
    a.email = Faker::Internet.email
    a.address = Faker::Address.street_address
    a.city = Faker::Address.city
    a.zip = Faker::Address.zip
    a.phone = Faker::PhoneNumber.phone_number
    a.country = Faker::Address.country
  end
end

100.times do |n|
  #print n.to_s + "\n"
  Book.create do |b|
    b.name = Faker::Book.title
    b.isbn = Faker::Code.isbn
    b.genre = Faker::Book.genre
    b.publisher = Faker::Book.publisher
    b.author_id = rand(10) + 1
  end
end
